import pymysql
from python_baway.common.xcommon import xshow_table
from python_baway.common.xdb import xdb_args


def xrun_sql(xsql):
    xrows = xcursor.execute(xsql)
    print(xrows)
    xtable = xcursor.fetchall()
    print(repr(xtable))
    xshow_table(xtable)


with pymysql.connect(**xdb_args) as xconnect:
    with xconnect.cursor() as xcursor:
        sql = "show databases"
        xrun_sql(sql)
        sql = "select * from rateok"
        xrun_sql(sql)
